﻿using EmoneyWeiXinCommon;
using EmoneyWeiXinEntity;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace EmoneyWeiXinDAL
{
    public class TJ_Business_MotionDataDAL
    {
        public List<TJ_Business_MotionDataEntity> GetMotionListForPage(string startTime, string endTime, int research, int weixinId, int wType, int pageSize, int pageIndex, out int totalCount,out int sumPv,out int sumUv)
        {
            //PageHelper pgHelper = new PageHelper("TJ_Business_MotionData", "id");
            //pgHelper.CurrentPage = pageIndex;
            //pgHelper.PageSize = pageSize;
            //pgHelper.WhereText = whereText;
            //DataTable dt = pgHelper.GetData();
            //totalPage = pgHelper.TotalRecord;
            //return SQLHelper.DataConvert<TJ_Business_MotionDataEntity>(dt);
            SQLTools tools = new SQLTools();
            tools.AddSqlParameter("startTime", SqlDbType.VarChar, startTime);
            tools.AddSqlParameter("endTime", SqlDbType.VarChar, endTime);
            tools.AddSqlParameter("research", SqlDbType.Int, research);
            tools.AddSqlParameter("wType", SqlDbType.Int, wType);
            tools.AddSqlParameter("weixinId", SqlDbType.Int, weixinId);
            tools.AddSqlParameter("pageIndex", SqlDbType.Int, pageIndex);
            tools.AddSqlParameter("pageSize", SqlDbType.Int, pageSize);
            SqlParameter[] paras = tools.GetSqlParameters();
            DataSet ds = SQLHelper.ExecuteGetDataSet(Config.EmoneyWeiXin, CommandType.StoredProcedure, "proc_GetDataMotionData", paras);
            totalCount = Convert.ToInt32(ds.Tables[1].Rows[0][0]);
            DataTable dt = ds.Tables[0];
            sumPv = Convert.ToInt32(ds.Tables[2].Rows[0][0]);
            sumUv = Convert.ToInt32(ds.Tables[2].Rows[0][1]);
            return SQLHelper.DataConvert<TJ_Business_MotionDataEntity>(dt);

        }
    }
}
